package com.zsc.edu.testcommonui;

import androidx.appcompat.app.AppCompatActivity;

import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

    final static String TAG = "---MainActivity---";

    Button button;
    TextView textView;
    EditText editText;
    ImageView imageView;

    boolean bZsc = true;


    private class MyProgressDialog extends ProgressDialog{
        public MyProgressDialog(Context context) {
            super(context);
        }

        public MyProgressDialog(Context context, int theme) {
            super(context, theme);
        }

        @Override
        protected void onStop() {
            super.onStop();

            Log.d(TAG, "MyPrgDia onStop");

            textView.setText("加载完毕");
        }
    }


    private class ButtonClicker implements View.OnClickListener{
        @Override
        public void onClick(View view) {
            // Todo 在此处 Log
            Log.d(TAG, "实名类");
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        button = findViewById(R.id.button);
        textView = findViewById(R.id.text_view);
        editText = findViewById(R.id.edit_text);
        imageView = findViewById(R.id.image_view);

        // 匿名类
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // Todo 在此处 Log
                //Log.d(TAG, "匿名类");

                if(bZsc) {
                    textView.setText("Hello Zsc");
                    textView.setTextColor(Color.RED);
                    imageView.setImageResource(R.drawable.cs);

                }else{
                    textView.setText("Hello World");
                    textView.setTextColor(Color.BLUE);
                    imageView.setImageResource(R.drawable.zsc);
                }

                bZsc = !bZsc;

                //editText.getText();

                Log.d(TAG, editText.getText().toString());

                MyProgressDialog progressDialog = new MyProgressDialog(MainActivity.this);
                progressDialog.setTitle("This is ProgressDialog");
                progressDialog.setMessage("Loading...");
                progressDialog.setCancelable(true);
                progressDialog.show();

            }
        });

        // 实名类
//        ButtonClicker buttonClicker = new ButtonClicker();
//        button.setOnClickListener(buttonClicker );

        // 设置
//        button.setOnClickListener(MainActivity.this);

    }

    @Override
    public void onClick(View view) {
        // Todo 在此处 Log
        Log.d(TAG, "MainActivity implement");


    }
}
